﻿using System;

namespace PivotData
{
    /// <summary>
    /// Data represneting the facet catagory information we know about.
    /// </summary>
    [Serializable]
    public class FacetCategory
    {
        /// <summary>
        /// Name of the facet
        /// </summary>
        public string Name;

        /// <summary>
        /// Can we search for this facet in the search box?
        /// </summary>
        public bool IsWordWheelVisible;

        /// <summary>
        /// Will this facet appear in the "Sort" dropdown and the filter pane on the left hand side?
        /// </summary>
        public bool IsFilterVisible;

        /// <summary>
        /// Will this facet appear in the metadata?
        /// </summary>
        public bool IsMetaDataVisible;

        /// <summary>
        /// The format string for a number facet.
        /// </summary>
        /// <remarks>Only formats that are allowed in .NET are valid. See http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx for more info.</remarks>
        public string NumberFormat;

        /// <summary>
        /// Do a deep equals comparison.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            var other = obj as FacetCategory;
            if (other == null)
                return false;

            return Name == other.Name
                && IsWordWheelVisible == other.IsWordWheelVisible
                && IsFilterVisible == other.IsFilterVisible
                && IsMetaDataVisible == other.IsMetaDataVisible
                && NumberFormat == other.NumberFormat;
        }

        public FacetCategory()
        {
            Name = "";
            NumberFormat = "";
            IsWordWheelVisible = true;
            IsFilterVisible = true;
            IsMetaDataVisible = true;
        }
    }
}
